#ifndef TYPEDEF_H
#define TYPEDEF_H

#include	<stdio.h> 

typedef enum _Ret
{
	RET_OUT_OF_MEM,
	RET_INVALID_PARAM,
	RET_FAIL,
	RET_OK
} Ret;

typedef enum _Direct
{
	DIRECT_FORWARD,
	DIRECT_BACKWARD
} Direct;

typedef void (*DataDestroyFunc)(void *ctxt, void *data);
typedef void *(*DataAllocFunc)(void *ctxt, size_t size);
typedef int (*DataCmpFunc)(void *ctxt, void *data);
typedef void (*DataVisitFunc)(void *ctxt, void *data);

#define swap_entry(struct_name, thiz, entry) \
		struct_name##_entry_swap(thiz, entry)

#define valid_entry(struct_name, thiz, entry) \
		struct_name##_entry_value(thiz, entry)

#define next_entry(struct_name, thiz, entry) \
		struct_name##_next_entry(thiz, entry)

#define get_entry_value(struct_name, thiz, entry, type) \
		*(type *)(struct_name##_entry_value(thiz, entry));

#define free_pointer(p) { free(p); p = NULL; }

#define return_val_if_fail(p, ret) if (!(p)) \
	{ printf("%s:%d Warning: "#p" failed.\n", \
		__func__, __LINE__); return (ret); }

#define return_if_fail(p) if (!(p)) \
	{ printf("%s:%d Warning: "#p" failed.\n", \
		__func__, __LINE__); return ; }
#endif
